﻿/**
 * Masque StringBuiler Library 0.0.1
 * Copyright(c) 2008, 青岛领创网络科技有限公司
 * @author Lookingon Team
 * 功能：快速字符串链接（类似于C＃中的StringBuiler）
 */


Masque.StringBuilder = function(iniStr){
    this.characters = new Array();

    if (typeof Masque.StringBuilder.prototype._initialized == "undefined") {
        Masque.StringBuilder.prototype.add = Masque.StringBuilder.prototype.append = function(addStr){
            if (addStr != null && addStr.length > 0) 
                this.characters.push(addStr);
            return this;
        };
        Masque.StringBuilder.prototype.toString = function(){
            return this.characters.join('');
        };
        Masque.StringBuilder.prototype.join = function(sp){
            return this.characters.join(sp);
        };
        
        Masque.StringBuilder.prototype.lastChar = function(){
            if (this.characters.length == 0) 
                return "";
            
            var lastStr = this.characters[this.characters.length - 1];
            if (lastStr.length == 0) 
                return "";
            
            return lastStr[lastStr.length - 1];
        };
        
        Masque.StringBuilder.prototype.isEmpty = function(){
            return this.characters.length == 0;
        };
        Masque.StringBuilder.prototype._initialized = true;
    }
	
	if (iniStr != null) 
        this.add(iniStr);
}


